public class Solution {
    //无重复字符的最长子串
    public int lengthOfLongestSubstring(String s) {
        int[] hash = new int[128];
        int left = 0;
        int right = 0;
        int n = s.length();
        int ret = 0;
        while(right < n) {
            hash[s.charAt(right)]++;
            while(hash[s.charAt(right)] > 1) {
                hash[s.charAt(left)]--;
                left++;
            }
            ret = Math.max(ret, right-left+1);
            right++;
        }
        return ret;
    }
}
